/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* E.P. Scene Graph Viewer
* Developed by:
*       - Eduardo Ribeiro (eribeiro @ tecgraf . puc-rio . br)
*       - Peter Dam (peter @ tecgraf . puc-rio . br)
* File: OBJReader.h
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#ifndef _EPSG_OBJREADER_
#define _EPSG_OBJREADER_

#include "EPSG/Mesh.h"
#include "EPSG/Vec3.h"
#include <string>
#include <vector>

namespace EPSG
{
	class OBJReader
	{
	public:
		/* [CONSTRUCTOR] */	OBJReader();
		
		void				read( const char* filename, 
								  int& nVertices, int& nTriangles,
								  Vertex* vertices, Vertex* vertexArray,
								  Triangle* triangles, BoundingBox& bBox,
								  TexCoord* texCoords );

	private:
		void				pushV( std::string line );
		void				pushVT( std::string line );
		void				pushVN( std::string line );
		void				pushF( std::string line );

		Vec3<float>			calcNormal( Triangle* t );

		int							_nVertices;
		int							_nNormals;
		int							_nTriangles;

		std::vector<EPSG::Vertex>	_vertices;
		std::vector<EPSG::Vertex>	_vertexArray;
		std::vector<EPSG::Triangle>	_triangles;
		std::vector<EPSG::TexCoord>	_texCoords;
		std::vector<EPSG::TexCoord>	_texCoordArray;

		EPSG::BoundingBox			_bBox;
	};
}

#endif // _EPSG_OBJREADER_